$(function(){
	localStorage.setItem("username",localStorage.getItem('username'));
	$(".user_number").html(localStorage.getItem("username"));
	$('#myPhone').val(localStorage.getItem("username"));
	$(".btn").bind('click',function(){
		subData();
	});
});
function checkStrLength(userPass, min, max) {// 验证密码
	if (userPass.length < min || userPass.length > max) {
		easyAlert("密码长度须在" + min + "-" + max + "之间!");
		return false;
	} else {
		return true;
	}
}
function subData(){
	//alert($("#myPhone").val());
	//var jsonObj = $("#formdata").serializeArray();
	//alert(equals($("#newpasswd").val(),$("#newpasswd1").val()));
	
		if(checkStrLength($("#newpasswd").val(),6,16)&&equals($("#newpasswd").val(),$("#newpasswd1").val())){
			var jsonObj = [];
			jsonObj.push({name:"username",value:$("#myPhone").val()});
			jsonObj.push({name:"oldpasswd",value:$("#oldpasswd").val()});
			jsonObj.push({name:"newpasswd",value:$("#newpasswd").val()});
			jsonObj.push({name:"codeUuid",value:localStorage.getItem("phoneNoUUID")});
			jsonObj.push({name:"code",value:$("#yzm").val()});
			$.ajax({
				type:'post',
				url:server_url+'rest/frontUser/updatePwd.do?ran='+Math.random(),
				data:jsonObj,
				dataType:'json',
				error:function(){alert(contants.systemError);},
				success:function(data){
					alert(data.retMsg);
					setTimeout(function(){
						localStorage.removeItem("username");
						window.location.href=server_url+"login.do";
					},1000);
				}
			});
			
			
			
		}else{
			alert(contants.notEquals);return;
		}
		
		//alert(JSON.stringify(jsonObj));
		/*var jsonObj = $("#formdata").serializeArray();
		alert(JSON.stringify(jsonObj));*/
	/*	if(yanzheng($("#myPhone"),$("#code"))){
	}else{
		alert(contants.notIsPhone);
		return;
	}*/
}
